package com.xjgc.ws.server.impl;

import com.xjgc.ws.eip.dao.ZxjEip2cAufnr;
import com.xjgc.ws.eip.dao.ZxjEip2cVbeln;
import com.xjgc.ws.general.dao.Zxjzsdtstr003;
import com.xjgc.ws.mes.dao.*;
import com.xjgc.ws.server.SapToMsi;
import com.xjgc.ws.util.test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.SQLException;
import java.text.ParseException;

/**
 * SapToMsi接口服务实现类
 * @author jjg-pc
 */
@Service
public class SapToMsiImpl implements SapToMsi {
//	String OldSerialNumber = null;
	@Autowired
	ZxjEip2cAufnr zxjEip2cAufnr;
	@Autowired
	ZxjMesAufnr zxjMesAufnr;
	@Autowired
	ZxjMesRsnum zxjMesRsnum;
	@Autowired
	ZxjMesLifnr zxjMesLifnr;
	@Autowired
	ZxjMesEbeln zxjMesEbeln;
	@Autowired
	ZxjMesMatnr zxjMesMatnr;
	@Autowired
	ZxjMesMblnr zxjMesMblnr;
	@Autowired
	ZxjMesStlnr zxjMesStlnr;
	@Autowired
	ZxjEip2cVbeln zxjEip2cVbeln;
	@Autowired
	ZxjMesVbeln zxjMesVbeln;
	@Autowired
	ZxjMesKunnr zxjMesKunnr;
	@Autowired
	ZxjMesVbelv zxjMesVbelv;
	@Autowired
	ZxjS2Mfhhc zxjS2Mfhhc;
	@Autowired
	ZxjS2Mcprk zxjS2Mcprk;
	@Autowired
	ZxjMesWerks zxjMesWerks;
	@Autowired
	private Zxjzsdtstr003 zxjzsdtstr003;

	String mkId = null;


	@Override
	public String pushData(String tName, String serialNumber, String xmlData, String arg1) {
		String rs= null;
		
		try {
			if("ZXJ_MES_AUFNR".equals(tName)) {
				zxjEip2cAufnr.aufnr(xmlData);//EIP生产订单
				rs = zxjMesAufnr.aufnr(xmlData);//MES生产订单
			}else if("ZXJ_MES_RSNUM".equals(tName)){//生产订单组件
				rs = zxjMesRsnum.rsnum(xmlData);
			}else if("ZXJ_MES_EBELN".equals(tName)){//采购订单
				rs = zxjMesEbeln.ebeln(xmlData);
			}else if("ZXJ_MES_LIFNR".equals(tName)){//供应商主数据
				rs = zxjMesLifnr.lifnr(xmlData);
			}else if("ZXJ_MES_MATNR".equals(tName)){//物料主数据
				rs = zxjMesMatnr.matnr(xmlData);
			}else if("ZXJ_MES_MBLNR".equals(tName)){//物料出入库
				rs = zxjMesMblnr.mblnr(xmlData);
			}else if("ZXJ_MES_STLNR".equals(tName)){//BOM数据表
				rs = zxjMesStlnr.stlnr(xmlData);
			}else if("ZXJ_MES_VBELN".equals(tName)){
				zxjEip2cVbeln.vbelnJudgeBySupplier(xmlData);//EIP销售订单
				rs = zxjMesVbeln.vbeln(xmlData);//MES销售订单
			}else if("ZXJ_MES_KUNNR".equals(tName)){//客户主数据
				rs = zxjMesKunnr.kunnr(xmlData);
			}else if("ZXJ_MES_VBELV".equals(tName)){//销售发货通知单
				rs = zxjMesVbelv.vbelv(xmlData);
			}else if("ZXJ_M2S_FHHC".equals(tName)){//SAP销售发货回传
				rs = zxjS2Mfhhc.fhhc(xmlData);
			}else if("ZXJ_M2S_CPRK".equals(tName)){//SAP成品入库回传
				rs = zxjS2Mcprk.fhhc(xmlData);
			}else if("ZXJ_MES_WERKS".equals(tName)){//MES工厂主数据接口
				rs = zxjMesWerks.werks(xmlData);
			}else if("ZSDT_STR_003".equals(tName)){//通用逾期欠款表接口
				rs = zxjzsdtstr003.work(xmlData);
			}else{
				test t = new test();
				rs = t.tsmsup(xmlData);
			}	
//			OldSerialNumber = serialNumber;
		} catch (SQLException | ParseException e) {
			// TODO Auto-generated catch block
			rs =e.toString();
			e.printStackTrace();
		}
		return rs;
	}



		
}

